package org.aom.service.base;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

public interface IEntityManager<T, PK extends Serializable> {

	T get(final PK id);

	Page<T> getAll(final Page<T> page);

	List<T> getAll();

	List<T> getAllDistinct();

	Page<T> search(final Page<T> page, final List<PropertyFilter> filters);

	void save(final T entity);

	void delete(final PK id);

	T findByUniqueProperty(String propertyName, Object val);

	List<T> findBy(final String propertyName, final Object value);

	List<T> findByIds(PK[] ids);

	List<T> getElementsById(String[] idArray) throws ClassCastException;

	List<T> getElements(DetachedCriteria dc, int start, int limit,
			String sortName, boolean direction);

	List<T> findByHql(String hql, Object... values);

	List<T> getElements(int start, int limit, String sortName, boolean direction);

	Integer totalCount(DetachedCriteria dc);
	
	Integer totalCount();
}
